package com.qt.myio;

import com.sun.scenario.effect.impl.sw.sse.SSEBlend_SRC_OUTPeer;

import java.io.*;

/**
 * @Author zsf
 * @Date 2023/9/24 14:41
 * @Version 1.0
 */
public class ByteStreamDemo02 {

    public static void main(String[] args) throws IOException {


        //extracted();

        /**
         * 字符流
         */
        //无参：read()
        /*FileReader fr = new FileReader("aaa\\a.txt");
        int len;
        while ((len = fr.read() )!= -1){
            System.out.print((char)len);
        }*/

        //有参：read(char[])

        FileReader fr = new FileReader("aaa\\a.txt");
        int len;
        char[] chars = new char[2];
        while((len = fr.read(chars)) != -1){
            System.out.print(new String(chars,0,len));
        }





    }

    private static void extracted() throws UnsupportedEncodingException {
        /**
         *编码  和 解码
         */

        String str = "abc哈撒肯";

        byte[] bytes = str.getBytes("UTF-8");
        String gbkStr = new String(bytes, "GBK");
        System.out.println(gbkStr);

        String utfStr = new String(bytes, "UTF-8");
        System.out.println(utfStr);
    }

}
